﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IntelligentDecisioning.SharePoint.Definition;
using Microsoft.SharePoint;
using IntelligentDecisioning.SharePoint.BusinessEntities;
using Microsoft.Practices.SPG.Common.ListRepository;
using IntelligentDecisioning.SharePoint.Helpers;
using IntelligentDecisioning.SharePoint.Definition.Lists;

namespace IntelligentDecisioning.SharePoint.Definitions
{
    public class DemonstrationTaskList : SharePointTaskList 
    {
      
       

        public DemonstrationTaskList()
            :base("Demo Task List")
        {
           
        }



        public List<DemonstrationTaskEntity> GetTasks(SPWeb targetWeb)
        {
            ListItemFieldMapper<DemonstrationTaskEntity> entityFieldMapper = new ListItemFieldMapper<DemonstrationTaskEntity>();
            entityFieldMapper.FieldMappings = GetFieldMappings();

            List<DemonstrationTaskEntity> tasks = new List<DemonstrationTaskEntity>();
            IDListHelper listHelper = new IDListHelper(targetWeb.Site, targetWeb);
            SPList demonstrationTaskList = listHelper.GetList(Name);
    
            foreach (SPListItem item in demonstrationTaskList.Items)
            {
                DemonstrationTaskEntity demonstrationTaskEntity = entityFieldMapper.CreateEntity(item);
                tasks.Add(demonstrationTaskEntity);
            }

            return tasks;
        }
    }
}
